﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageGalery.aspx.cs" Inherits="ImageGalery"
    EnableViewState="false" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>

<%@ Register Assembly="ESWebControls" Namespace="ESWebControls" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script src="Scripts/GeneralScripts.js"></script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="item floatbox">
            <h5>
                <asp:Label ID="ProductTitleLabel" runat="server" /></h5>
            <div class="body">
                <p>
                    <asp:Literal runat="server" meta:resourcekey="ViewsDescription" />
                </p>
                <asp:ListView InsertItemPosition="LastItem" ID="ProductImagesList" runat="server"
                    DataKeyNames="ImageId" DataSourceID="ProductImagesODS">
                    <LayoutTemplate>
                        <div class="floatbox">
                            <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
                        </div>
                    </LayoutTemplate>
                    <InsertItemTemplate>
                        <%--<% if (Roles.IsUserInRole("Administrator"))
                                       { %>
                                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" meta:resourcekey="InsertButtonResource1" />
                                    <% } %>--%>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <noscript>
                            <div class="ImageTumbnail float_left">
                        </noscript>

                        <script>
                                var link = "<div class=\"ImageTumbnail float_left\" onclick=\"" +
                                           "showImageViewer('small_image_<%# Eval("ImageId") %>', '<%= DefImage.ClientID %>'); return false\">";
                                document.write(link);
                        </script>

                        <noscript>
                            <a href='ImageGalery.aspx?imageId=<%# Eval("ImageId") %>&ProductId=<%# Eval("ProductId") %>'>
                                <img style="vertical-align: middle; border-width: 0px" onclick="setImageBorder('alt_image_0');showImageViewer('alt_image_0'); return false"
                                    src='GetTumbnail.ashx?boxsize=80&FileName=<%# Eval("Url") %>' id='small_image_<%# Eval("ImageId") %>' />
                            </a>
                        </noscript>

                        <script>
                                                var link = "<img style=\"vertical-align: middle; border-width:0px\"" +
                                                           " id=\"small_image_<%# Eval("ImageId") %>\"" +
                                                           " src=\"GetTumbnail.ashx?boxsize=80&FileName=<%# Eval("Url") %>\" />";
                                                document.write(link);
                        </script>

                        </div>
                    </ItemTemplate>
                </asp:ListView>
                <hr />
                <%--<% if (Roles.IsUserInRole("Administrator"))
                               { %>
                            <asp:FileUpload runat="server" ID="ImageUpload" meta:resourcekey="ImageUploadResource1" />
                            <% } %>--%>
                <div id="imageViewerDiv" class="ProductImage" style="background-color: White;">
                    <asp:Image ID="DefImage" runat="server" />
                </div>
            </div>
        </div>
    </div>
    <asp:ObjectDataSource ID="ProductImagesODS" runat="server" DeleteMethod="DeleteProductImage"
        InsertMethod="InsertProductImage" SelectMethod="SelectProductImages" TypeName="DAL.ProductImage">
        <DeleteParameters>
            <asp:Parameter Name="productImageId" Type="Int32" />
        </DeleteParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="productId" QueryStringField="productId" Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:QueryStringParameter Name="productId" QueryStringField="productId" Type="Int32" />
            <asp:ControlParameter ControlID="AppUtility" Name="physicalApplicationPath" PropertyName="AppPath"
                Type="String" />
            <asp:ControlParameter ControlID="ImageUpload" Name="httpPostedFile" PropertyName="PostedFile"
                Type="Object" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:LinqDataSource ID="ProductImagesDS" runat="server" ContextTypeName="DAL.EShopDBDataContext"
        TableName="ProductImages" Where="ProductId == @ProductId">
        <WhereParameters>
            <asp:QueryStringParameter Name="ProductId" QueryStringField="productId" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
    <cc1:ApplicationUtility ID="AppUtility" runat="server" />
    </form>
</body>
</html>
